<?php
namespace Api\Controller;

class NoticeController extends ApiController {
    
    public function getList() {
        $page = I('post.page', 1);
        $pagesize = I('post.pagesize', 10);
        $offset = ($page-1) * $pagesize;
        
        $result['total'] = M('notice')->count() | 0;
        $result['result'] = M('notice')->limit($offset,$pagesize)->order('id DESC')->select();
        foreach ($result['result'] as &$re ){
            $img='src="http://112.74.14.50/Uploads';
            $re['content']=str_replace('src="/Uploads',$img,$re['content']);
            $re['update_time'] = date('Y-m-d H:i', $re['update_time']);
        }
        response(1, $result);
    }
    
    public function getDetail() {
        $id = I('post.id', 0);
        $where['id']=$id;
        $info = M('notice')->where($where)->find();
        $info['update_time'] = date('Y-m-d H:i', $info['update_time']);
        $info || response(-1, null, '参数有误');
        response(1, $info);
    }
}